package com.changgou.goods.dao;

import com.changgou.goods.pojo.Brand;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Author seafwg
 * @Date 2021/11/21 2:10 下午
 * @Version 1.0
 * @description DAO接口需要继承Mapper<T> T:实体类
 */
public interface BrandMapper extends Mapper<Brand> {

    /**
     * 根据分类ID查询商品：
     * 根据分类ID查询分类商品表，根据此表中的商品品牌ID查询品牌表
     * select * from tb_category_brand where category_id = 558 -- 1150
     * select * from tb_brand where id = 1150;
     * select * from tb_category_brand tcb, tb_brand tb where tcb.category_id = 558 and tb.id = tcb.brand_id;
     * @param categoryId
     * @return
     */
    @Select("select * from tb_category_brand tcb, tb_brand where tcb.category_id=#{categoryId} and tb.id = tcb.brand_id")
    List<Brand> findBrandByCategoryId(Integer categoryId);
}
